using System;
using System.Collections.Generic;
using System.Text;
using Entities;
using DAL;
using Utility;

namespace BUS
{
    public class tbDiaDiemBUS
    {
        public static void Insert(tbDiaDiem diadiem)
        {
            tbDiaDiemDAL ddDAL = new tbDiaDiemDAL();
            ddDAL.Insert(diadiem);
        }
        public static void Update(tbDiaDiem diadiem)
        {
            tbDiaDiemDAL ddDAl = new tbDiaDiemDAL();
            ddDAl.Update(diadiem);
        }
        public static void Delete(int iD)
        {
            tbDiaDiemDAL ddDAl = new tbDiaDiemDAL();
            ddDAl.Delete(iD);
        }
        public static tbDiaDiemCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbDiaDiemDAL ddDAL = new tbDiaDiemDAL();
            return ddDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbDiaDiemCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbDiaDiemDAL ddDAL = new tbDiaDiemDAL();
            return ddDAL.Get(cri.Criter, 0, 0, tbDiaDiemColumns.MaDD.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbDiaDiem GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbDiaDiemColumns.MaDD.ToString(), Condition.EQUAL, iD);
            tbDiaDiemDAL ddDAL = new tbDiaDiemDAL();
            tbDiaDiemCollection ddCollection = ddDAL.Get(cri.Criter, 0, 0, tbDiaDiemColumns.MaDD.ToString(), OrderDirection.ASC.ToString(), out total);
            if (ddCollection.Count > 0)
                return ddCollection[0];
            return null;
        }
        public static tbDiaDiemCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbDiaDiemDAL ddDAL = new tbDiaDiemDAL();
            return ddDAL.Get(cri.Criter, 1, number, tbDiaDiemColumns.MaDD.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbDiaDiemCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbDiaDiemDAL ddDAL = new tbDiaDiemDAL();
            return ddDAL.Get(cri.Criter, 1, number, tbDiaDiemColumns.MaDD.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}